/**
 * 
 */
package complexes;

/**
 * @author valentin
 *
 */
public class AlgeComplexe implements Complexe
{
	private double re, im;
	
	public AlgeComplexe(double re, double im)
	{
		this.re = re;
		this.im = im;
	}

	/* (non-Javadoc)
	 * @see complexes.Complexe#getRe()
	 */
	@Override
	public double getRe()
	{
		
		return re;
	}

	/* (non-Javadoc)
	 * @see complexes.Complexe#getIm()
	 */
	@Override
	public double getIm()
	{
		return im;
	}

	/* (non-Javadoc)
	 * @see complexes.Complexe#getModule()
	 */
	@Override
	public double getModule()
	{
		return Math.sqrt(re*re + im*im);
	}

	/* (non-Javadoc)
	 * @see complexes.Complexe#getArgument()
	 */
	@Override
	public Angle getArgument()
	{
		return new Angle(Math.copySign(Math.acos(re/getModule()), Math.asin(im/getModule())));
	}
	
	public boolean equals(Object o)
	{
		if(!(o instanceof Complexe))
			return false;
		else
			return re == ((Complexe)o).getRe() && im == ((Complexe)o).getIm();
	}
	
	public String toString()
	{
		return "z = " + re + " + " + im + "i";
	}
}
